home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / graphics / gnuplot / term / corel.trm < prev    next >
Text File  |  1993-09-15  |  11KB  |  345 lines

  1. /*
  2.  * $Id: corel.trm%v 3.50 1993/07/09 05:35:24 woo Exp $
  3.  */
  4.  
  5. /*
  6.    corel.trm
  7.  
  8.    A modified ai.trm for CorelDraw import filters
  9.    by Chris Parks, parks@physics.purdue.edu
  10.    Import from CorelDraw with the CorelTrace filter
  11.  
  12.    syntax: set terminal default
  13.            set terminal mode "fontname" fontsize,xsize,ysize,linewidth
  14.  
  15.            mode= color or monochrome             (default=mono)
  16.            "fontname"= postscript font name      (default="SwitzerlandLight")
  17.            fontsize  = size of font in points    (default=22pt)
  18.            xsize     = width of page in inches   (default=8.2in)
  19.            ysize     = height of page in inches  (default=10in)
  20.            linewidth = width of lines in points  (default=1.2pt)
  21.  
  22. */
  23.  
  24. /* plots for publication should be sans-serif (don't use TimesRoman) */
  25. char corel_font[MAX_ID_LEN+1] = "SwitzerlandLight" ; /* name of font */
  26. int corel_fontsize = 22;                            /* size of font in pts */
  27. TBOOLEAN corel_color = FALSE;
  28. TBOOLEAN corel_stroke = FALSE;
  29. int corel_path_count=0;            /* count of lines in path */
  30. int corel_ang=0;                   /* text angle */
  31. enum JUSTIFY corel_justify=LEFT;   /* text is flush left */
  32.  
  33.  
  34. /* default mode constants */
  35. #define CORELD_XOFF  0               /* page offset in pts */
  36. #define CORELD_YOFF  0
  37. #define COREL_SC     (10.0)           /* scale is 1pt = 10 units */
  38. #define CORELD_LW    (1.2*COREL_SC)  /* linewidth = 1.2 pts */
  39. #define CORELD_XMAX  5960            /* 8.2 inches wide */
  40. #define CORELD_YMAX  7200            /* 10 inches high  */
  41. #define CORELD_VTIC  (CORELD_YMAX/80)
  42. #define CORELD_HTIC  (CORELD_YMAX/80)
  43. #define CORELD_VCHAR (22*COREL_SC)      /* default is 22 point characters */
  44. #define CORELD_HCHAR (22*COREL_SC*6/10)
  45.  
  46. unsigned int corel_xmax=CORELD_XMAX;
  47. unsigned int corel_ymax=CORELD_YMAX;
  48. float corel_lw=CORELD_LW;
  49.  
  50. COREL_options()
  51. {
  52.     extern struct value *const_express();
  53.     extern double real();
  54.         struct value a;
  55.  
  56.                 if (!END_OF_COMMAND && almost_equals(c_token,"def$ault")) {
  57.                         corel_color=FALSE;
  58.                         strcpy(corel_font,"SwitzerlandLight");
  59.                         corel_fontsize = 22;
  60.                         corel_lw=CORELD_LW;
  61.                 corel_xmax=CORELD_XMAX;
  62.                 corel_ymax=CORELD_YMAX;
  63.             c_token++;
  64.                 }
  65.                 if (!END_OF_COMMAND && almost_equals(c_token,"mono$chrome")) {
  66.                         corel_color=FALSE;
  67.             c_token++;
  68.                 } else
  69.                 if (!END_OF_COMMAND && almost_equals(c_token,"color$")) {
  70.                         corel_color=TRUE;
  71.             c_token++;
  72.                 }
  73.                 if (!END_OF_COMMAND && isstring(c_token)) {
  74.                   quote_str(corel_font,c_token);
  75.                   c_token++;
  76.                 }
  77.                 if (!END_OF_COMMAND) {
  78.                   /* We have font size specified */
  79.                   corel_fontsize = (int)real(const_express(&a));
  80.                   c_token++;
  81.                   term_tbl[term].v_char = (unsigned int)(corel_fontsize*COREL_SC);
  82.                   term_tbl[term].h_char = (unsigned int)(corel_fontsize*COREL_SC*6/10);
  83.                 }
  84.                 if (!END_OF_COMMAND) {
  85.                   corel_xmax=(unsigned int)(real(const_express(&a))*720);
  86.                   c_token++;
  87.                   if (!END_OF_COMMAND) {
  88.                     corel_ymax=(unsigned int)(real(const_express(&a))*720);
  89.                     c_token++;
  90.                   }
  91.                   term_tbl[term].xmax=corel_xmax;
  92.                   term_tbl[term].ymax=corel_ymax;
  93.                   term_tbl[term].v_tic=corel_ymax/80;
  94.                   term_tbl[term].h_tic=corel_ymax/80;
  95.                 }
  96.                 if (!END_OF_COMMAND) {
  97.                   corel_lw= real(const_express(&a))*COREL_SC;
  98.                   c_token++;
  99.                 }
  100.  
  101.         sprintf(term_options,"%s \"%s\" %d,%0.1f,%0.1f,%0.1f",
  102.                 corel_color ? "color" : "monochrome",corel_font,
  103.                 corel_fontsize,corel_xmax/720.0,corel_ymax/720.0,
  104.                 corel_lw/COREL_SC);
  105. }
  106.  
  107. COREL_init()
  108. {
  109.     fprintf(outfile,"%%!PS-Adobe-2.0 EPSF-1.2\n");
  110.         fprintf(outfile,"%%%%BoundingBox: %d %d %d %d\n", CORELD_XOFF,CORELD_YOFF,
  111.                 (int)((corel_xmax)/COREL_SC+0.5+CORELD_XOFF),
  112.                 (int)((corel_ymax)/COREL_SC+0.5+CORELD_YOFF) );
  113.         fprintf(outfile,"%%%%TemplateBox: %d %d %d %d\n", CORELD_XOFF,CORELD_YOFF,
  114.                 (int)((corel_xmax)/COREL_SC+0.5+CORELD_XOFF),
  115.                 (int)((corel_ymax)/COREL_SC+0.5+CORELD_YOFF) );
  116.     fprintf(outfile,"%%%%EndComments\n");
  117.     fprintf(outfile,"%%%%EndProlog\n");
  118.         fprintf(outfile,"%%%%BeginSetup\n%%%%EndSetup\n");
  119. }
  120.  
  121.  
  122. COREL_graphics()
  123. {
  124.         corel_path_count = 0;
  125.         corel_stroke = FALSE;
  126. }
  127.  
  128.  
  129. COREL_text()
  130. {
  131.         if (corel_stroke) {
  132.         fprintf(outfile,"S\n");
  133.                 corel_stroke = FALSE;
  134.     }
  135.         corel_path_count = 0;
  136. }
  137.  
  138.  
  139. COREL_reset()
  140. {
  141.     fprintf(outfile,"%%%%Trailer\n");
  142. }
  143.  
  144.  
  145. COREL_linetype(linetype)
  146. int linetype;
  147. {
  148.         if (corel_stroke) {
  149.         fprintf(outfile,"S\n");
  150.                 corel_stroke = FALSE;
  151.     }
  152.     switch(linetype) {
  153.                 case -2 : fprintf(outfile,"%.2f w\n",corel_lw/COREL_SC);
  154.                                 if (corel_color) {
  155.                     fprintf(outfile,"0 0 0 1 K\n");
  156.                 }
  157.                 else {                
  158.                                         fprintf(outfile,"[] 0 d\n");
  159.                                         fprintf(outfile,"0 j\n0 G\n");
  160.                 }
  161.                 break;
  162.  
  163.                 case -1 : fprintf(outfile,"%.2f w\n",corel_lw/COREL_SC);
  164.                                 if (corel_color) {
  165.                     fprintf(outfile,"0 0 0 1 K\n");
  166.                 }
  167.                 else {                
  168.                     fprintf(outfile,"[1 2] 0 d\n");
  169.                                         fprintf(outfile,"0 j\n0 G\n");
  170.                                 }
  171.                 break;
  172.                 
  173.                 case 0 :  fprintf(outfile,"%.2f w\n",corel_lw/COREL_SC);
  174.                                 if (corel_color) {
  175.                     fprintf(outfile,"1 0 1 0 K\n");
  176.                 }
  177.                 else {                
  178.                     fprintf(outfile,"[] 0 d\n");
  179.                                         fprintf(outfile,"2 j\n0 G\n");
  180.                                 }
  181.                 break;
  182.                 
  183.                 case 1 :  fprintf(outfile,"%.2f w\n",corel_lw/COREL_SC);
  184.                                 if (corel_color) {
  185.                     fprintf(outfile,"1 1 0 0 K\n");
  186.                 }
  187.                 else {                
  188.                     fprintf(outfile,"[4 2] 0 d\n");
  189.                                         fprintf(outfile,"2 j\n0 G\n");
  190.                                 }
  191.                 break;
  192.                 
  193.                 case 2 :  fprintf(outfile,"%.2f w\n",corel_lw/COREL_SC);
  194.                                 if (corel_color) {
  195.                     fprintf(outfile,"0 1 1 0 K\n");
  196.                 }
  197.                 else {                
  198.                                         fprintf(outfile,"[2 3] 0 d\n");
  199.                                         fprintf(outfile,"2 j\n0 G\n");
  200.                                 }
  201.                 break;
  202.                 
  203.                 case 3 :  fprintf(outfile,"%.2f w\n",corel_lw/COREL_SC);
  204.                                 if (corel_color) {
  205.                     fprintf(outfile,"0 1 0 0 K\n");
  206.                 }
  207.                 else {                
  208.                     fprintf(outfile,"[1 1.5] 0 d\n");
  209.                                         fprintf(outfile,"2 j\n0 G\n");
  210.                                 }
  211.                 break;
  212.                 
  213.                 case 4 :  fprintf(outfile,"%f w\n",corel_lw/COREL_SC);
  214.                                 if (corel_color) {
  215.                     fprintf(outfile,"1 0 0 0 K\n");
  216.                                 }
  217.                 else {                
  218.                     fprintf(outfile,"[5 2 1 2] 0 d\n");
  219.                                         fprintf(outfile,"2 j\n0 G\n");
  220.                                 }
  221.                 break;
  222.                 
  223.                 case 5 : fprintf(outfile,"%.2f w\n",corel_lw/COREL_SC);
  224.                                 if (corel_color) {
  225.                     fprintf(outfile,"0 0 1 0 K\n");
  226.                 }
  227.                 else {                
  228.                     fprintf(outfile,"[4 3 1 3] 0 d\n");
  229.                                         fprintf(outfile,"2 j\n0 G\n");
  230.                                 }
  231.                 break;
  232.                 
  233.                 case 6 : fprintf(outfile,"%.2f w\n",corel_lw/COREL_SC);
  234.                                 if (corel_color) {
  235.                     fprintf(outfile,"0 0 0 1 K\n");
  236.                 }
  237.                 else {                
  238.                     fprintf(outfile,"[2 2 2 4] 0 d\n");
  239.                                         fprintf(outfile,"2 j\n0 G\n");
  240.                                 }
  241.                 break;
  242.                 
  243.                 case 7 : fprintf(outfile,"%.2f w\n",corel_lw/COREL_SC);
  244.                                 if (corel_color) {
  245.                     fprintf(outfile,"0 0.7 1 0 K\n");
  246.                 }
  247.                 else {                
  248.                     fprintf(outfile,"[2 2 2 2 2 4] 0 d\n");
  249.                                         fprintf(outfile,"2 j\n0 G\n");
  250.                                 }
  251.                 break;
  252.                 
  253.                 case 8 : fprintf(outfile,"%.2f w\n",corel_lw/COREL_SC);
  254.                                 if (corel_color) {
  255.                     fprintf(outfile,"0.5 0.5 0.5 0 K\n");
  256.                 }
  257.                 else {                
  258.                     fprintf(outfile,"[2 2 2 2 2 2 2 4] 0 d\n");
  259.                                         fprintf(outfile,"2 j\n0 G\n");
  260.                                 }
  261.                 break;
  262.         }
  263.         corel_path_count = 0;
  264. }
  265.  
  266.  
  267. COREL_move(x,y)
  268. unsigned int x,y;
  269. {
  270.         if (corel_stroke) fprintf(outfile,"S\n");
  271.         fprintf(outfile,"%0.2f %0.2f m\n", x/COREL_SC, y/COREL_SC);
  272.         corel_path_count += 1;
  273.         corel_stroke = TRUE;
  274. }
  275.  
  276.  
  277. COREL_vector(x,y)
  278. unsigned int x,y;
  279. {
  280.         fprintf(outfile,"%.2f %.2f l\n", x/COREL_SC, y/COREL_SC);
  281.         corel_path_count += 1;
  282.         corel_stroke = TRUE;
  283.         if (corel_path_count >= 400) {
  284.                 fprintf(outfile,"S\n%.2f %.2f m\n",x/COREL_SC,y/COREL_SC);
  285.                 corel_path_count = 0;
  286.     }
  287. }
  288.  
  289.  
  290. COREL_put_text(x,y,str)
  291. unsigned int x, y;
  292. char *str;
  293. {
  294. char ch;
  295.         if (corel_stroke) {
  296.         fprintf(outfile,"S\n");
  297.                 corel_stroke = FALSE;
  298.     }
  299.         switch(corel_justify) {
  300.                 case LEFT :   fprintf(outfile,"/_%s %d %d 0 0 z\n",
  301.                                       corel_font,corel_fontsize,corel_fontsize);
  302.             break;
  303.                 case CENTRE : fprintf(outfile,"/_%s %d %d 0 1 z\n",
  304.                                       corel_font,corel_fontsize,corel_fontsize);
  305.             break;
  306.                 case RIGHT :  fprintf(outfile,"/_%s %d %d 0 2 z\n",
  307.                                       corel_font,corel_fontsize,corel_fontsize);
  308.             break;
  309.     }
  310.         if (corel_ang==0) {
  311.                 fprintf(outfile,"[1 0 0 1 %.2f %.2f]e\n0 g\n",
  312.                         x/COREL_SC,y/COREL_SC - corel_fontsize/3.0);
  313.     }
  314.     else {
  315.                 fprintf(outfile,"[0 1 -1 0 %.2f %.2f]e\n0 g\n",
  316.                         x/COREL_SC - corel_fontsize/3.0,y/COREL_SC);
  317.     }
  318.         
  319.     putc('(',outfile);
  320.     ch = *str++;
  321.     while(ch!='\0') {
  322.         if ( (ch=='(') || (ch==')') || (ch=='\\') )
  323.             putc('\\',outfile);
  324.         putc(ch,outfile);
  325.         ch = *str++;
  326.     }
  327.         fprintf(outfile,")t\nT\n");
  328.         corel_path_count = 0;
  329. }
  330.  
  331. int COREL_text_angle(ang)
  332. int ang;
  333. {
  334.         corel_ang=ang;
  335.     return TRUE;
  336. }
  337.  
  338. int COREL_justify_text(mode)
  339. enum JUSTIFY mode;
  340. {
  341.         corel_justify=mode;
  342.     return TRUE;
  343. }
  344.  
  345.